package met.cs664.ai.cox.soc.strategies.placement;

import soc.game.SOCBoard;

import java.util.List;

/**
 * Player #4 will want to optimize on resources that provide early round advantages, such as brick and wood.
 * The second settlement placed immediately generates resources for adjacent hexes. Therefore prefer to
 * place a settlement with access to early game resources last.
 *
 * @author mcox
 */
public class PlayerFour extends AbstractEvaluator implements PlacementEvaluator {

    public PlayerFour(float weight) {
        super(weight);
    }

    public String toString() {
        return "PlayerFour";
    }

    @Override
    public void evaluateCandidates(SOCBoard board, List<PlacementCandidate> candidates) {
        int firstSettlementEarlyAccess = 0;
        PlacementCandidate candidate = candidates.get(0);
        for (int hexCoord : getAdjacentHexesToNode(candidate.getCoord())) {
            int resourceType = board.getHexTypeFromCoord(hexCoord);
            if (resourceType != SOCBoard.CLAY_HEX && resourceType != SOCBoard.WOOD_HEX) {
                firstSettlementEarlyAccess++;
            }
        }
        candidate.updateWeight(getWeight() * firstSettlementEarlyAccess);

        candidate = candidates.get(1);
        int secondSettlementEarlyAccess = 0;
        for (int hexCoord : getAdjacentHexesToNode(candidate.getCoord())) {
            int resourceType = board.getHexTypeFromCoord(hexCoord);
            if (resourceType != SOCBoard.CLAY_HEX && resourceType != SOCBoard.WOOD_HEX) {
                secondSettlementEarlyAccess++;
            }
        }
        candidate.updateWeight(getWeight() * secondSettlementEarlyAccess);
    }
}
